package com.bw.mapper;

import com.bw.bean.Vo;
import com.bw.bean.Vo1;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @Author:
 * @Date: 2025/3/19 08:49
 * @Description:
 **/
@Mapper
public interface VoMapper {
    @Select("select '运输次数' name,count(*)value\n" +
            "from transport_task where date(create_time)='2023-01-06'\n" +
            "union\n" +
            "select '运输里程' name,sum(actual_distance)value\n" +
            "from transport_task where date(create_time)='2023-01-06'\n" +
            "union\n" +
            "select '运输时长' name,sum(timestampdiff(second,actual_start_time,actual_end_time))value\n" +
            "from transport_task where date(create_time)='2023-01-06'")
    List<Vo> getList1();

    @Select("select count(*)value\n" +
            "from order_info where date(create_time)='2023-01-06'")
    Double getList2();

    @Select("select bo.org_name name,\n" +
            "       sum(tt.actual_distance)distance,\n" +
            "       count(tt.id)num,\n" +
            "       sum(timestampdiff(second,actual_start_time,actual_end_time))time,\n" +
            "       sum(timestampdiff(second,actual_start_time,actual_end_time))/count(tt.id)avgTime,\n" +
            "       sum(tt.actual_distance)/count(tt.id)avgDistance\n" +
            "from transport_task tt\n" +
            "left join line_base_info lbi on lbi.id = tt.line_id\n" +
            "left join base_organ bo on bo.id = lbi.org_id\n" +
            "group by bo.org_name")
    List<Vo1> getList3();

    @Select("select bri2.name,\n" +
            "       count(*)value\n" +
            "from express_task_delivery etd\n" +
            "left join base_organ bo on bo.id = etd.org_id\n" +
            "left join base_region_info bri on bri.id = bo.region_id\n" +
            "left join base_region_info bri2 on bri.parent_id=bri2.id\n" +
            "group by bri2.name")
    List<Vo> getList4();
}
